package com.QK.cnstudy;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;

public class CnGroup_Activity extends TabActivity implements OnClickListener {

    private TabHost mTabHost;
    private RadioGroup radioGroup;

    private RadioButton studyRadioButton;
    private RadioButton testRadioButton;
    private RadioButton statRadioButton;
    private RadioButton moreRadioButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cn_group_);
        getView();

        Intent studyIntent = new Intent(this, MaterialSelectActivity.class);
        Intent testIntent = new Intent(this, TestSelectActivity.class);
        Intent statIntent = new Intent(this, StatActivity.class);
        Intent moreIntent = new Intent(this, MoreActivity.class);

        mTabHost.addTab(mTabHost.newTabSpec("study").setIndicator("study").setContent(studyIntent));
        mTabHost.addTab(mTabHost.newTabSpec("test").setIndicator("test").setContent(testIntent));
        mTabHost.addTab(mTabHost.newTabSpec("stat").setIndicator("stat").setContent(statIntent));
        mTabHost.addTab(mTabHost.newTabSpec("more").setIndicator("more").setContent(moreIntent));

        studyRadioButton.setOnClickListener(this);
        testRadioButton.setOnClickListener(this);
        statRadioButton.setOnClickListener(this);
        moreRadioButton.setOnClickListener(this);

    }

    public void getView() {
        mTabHost = getTabHost();
        radioGroup = (RadioGroup) findViewById(R.id.tab_group);
        studyRadioButton = (RadioButton) findViewById(R.id.btn_study);
        testRadioButton = (RadioButton) findViewById(R.id.btn_test);
        statRadioButton = (RadioButton) findViewById(R.id.btn_stat);
        moreRadioButton = (RadioButton) findViewById(R.id.btn_more);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.btn_study:
            mTabHost.setCurrentTabByTag("study");
            break;
        case R.id.btn_test:
            mTabHost.setCurrentTabByTag("test");
            break;
        case R.id.btn_stat:
            mTabHost.setCurrentTabByTag("stat");
            break;
        case R.id.btn_more:
            mTabHost.setCurrentTabByTag("more");
            break;
        default:
            break;
        }

    }
}
